with Ada.Integer_Text_Io;
use Ada.Integer_Text_Io;
with Ada.Text_Io;
use Ada.Text_IO;

package body Matrix_Pkg is
   
   function "+"(M1 : Matrix; M2 : Matrix) return Matrix is
      R : Matrix := M1;
   begin
      for I in M2'range(1) loop
         for J in M2'range(2) loop
            R(I,J):=R(I,J)+M2(I,J);
         end loop;
      end loop;
      return R;
   end "+";
   
   function "*"(S : Integer; M: Matrix) return Matrix is
      R: Matrix:=M;   
   begin
      for I in M'range(1) loop
         for J in M'range(2) loop
            R(I,J):=S*R(I,J);
         end loop;
      end loop;
      return R;
   end "*";
   
   function "*"(M1: Matrix; M2: Matrix) return Matrix is
      M : Matrix := M1;
   begin 
      for I in M1'range(1) loop
         for J in M2'range(2) loop
            for L in M1'range(2) loop
               M(I,J):=M1(I,L)*M2(L,J);
            end loop;
         end loop;
      end loop;
      return M;
   end "*";
   
   Procedure Fill_Value(Value: in Integer; M: in out Matrix) is
   begin
      for I in M'range(1) loop
         for J in M'range(2) loop
            M(i,j):=value;
         end loop;
      end loop;
   end Fill_Value;
   
   procedure Write(M : in Matrix) is
   begin
      for I in M'range(1) loop
         for J in M'range(2) loop
            Put(M(I,J));
         end loop;
         Put_Line("");
      end loop;
   end Write;

   function Get_Declaration(M: Matrix) return Matrix_Declaration is
      decl: Matrix_Declaration;
   begin
      Decl:=(M'Length(1), M'Length(2));
      return (M'Length(1), M'Length(2));
   end Get_Declaration;
   
end Matrix_Pkg;

